import 'package:easy_read_comic/controller/comic/comic_look_for_controller.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class ComicLookForView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetBuilder(
      init: ComicLookForController(),
      builder: (controller) {
        return Scaffold(
          appBar: AppBar(
            title: Text(
              "帮找漫画",
              style: TextStyle(
                color: Colors.white,
              ),
            ),
            backgroundColor: Theme.of(context).primaryColor,
          ),
          body: Container(
            child: Form(
              key: controller.formKey,
              child: Column(
                children: [
                  Container(
                    child: TextFormField(
                      decoration: InputDecoration(
                        hintText: "漫画名称",
                        border: OutlineInputBorder(
                          borderRadius: BorderRadius.circular(10),
                        ),
                      ),
                      controller: controller.titleController,
                      validator: (value) {
                        if (value == null || value.isEmpty) {
                          return "请填写漫画标题";
                        }
                      },
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.only(
                      top: 10,
                    ),
                    child: TextFormField(
                      controller: controller.linkController,
                      decoration: InputDecoration(
                        hintText: "漫画链接,选填",
                        border: OutlineInputBorder(
                          borderRadius: BorderRadius.circular(10),
                        ),
                      ),
                    ),
                  ),
                  Expanded(
                    child: Container(
                      padding: EdgeInsets.only(
                        bottom: 10,
                        left: 10,
                        right: 10,
                      ),
                      alignment: Alignment.bottomCenter,
                      child: SizedBox(
                        width: MediaQuery.of(context).size.width,
                        height: 50,
                        child: TextButton(
                          onPressed: controller.submit,
                          child: Text(
                            "提交",
                            style: TextStyle(
                              color: Colors.white,
                            ),
                          ),
                          style: ButtonStyle(
                            backgroundColor: WidgetStateProperty.all(
                              Theme.of(context).primaryColor,
                            ),
                            shape:
                                WidgetStateProperty.all<RoundedRectangleBorder>(
                              RoundedRectangleBorder(
                                borderRadius: BorderRadius.circular(15.0),
                              ),
                            ),
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
            padding: EdgeInsets.all(20),
          ),
        );
      },
    );
  }
}
